package com.xian.im.web.modules.sys;

import com.xian.im.common.result.RestResult;
import com.xian.im.common.result.RestResultBuilder;
import com.xian.im.modules.sensitive.SensitiveBloomFactory;
import com.xian.im.modules.sensitive.handler.SensitiveBloom;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: xian-im-server
 * @description:
 * @author: liru.xian
 * @create: 2021-02-03 10:21
 **/
@RestController
@RequestMapping("im/sensitive")
@Api(value = "敏感词管理", tags = {"敏感词管理"})
public class SystemSensitiveController {

    @ApiOperation(value = "redis布隆 重新加载", notes = "redis布隆 重新加载")
    @RequestMapping(value = "/redis/bloom",method = RequestMethod.GET)
    public RestResult<Boolean> initRedis(){
        SensitiveBloomFactory.type(SensitiveBloom.REDIS_TYPE).loadSensitive();
        return RestResultBuilder.builder().success(Boolean.TRUE).build();
    }
    @ApiOperation(value = "guava布隆 重新加载", notes = "guava布隆 重新加载")
    @RequestMapping(value = "/guava/bloom",method = RequestMethod.GET)
    public RestResult<Boolean> initGuava(){
        SensitiveBloomFactory.type(SensitiveBloom.GUAVA_TYPE).loadSensitive();
        return RestResultBuilder.builder().success(Boolean.TRUE).build();
    }

}
